begintownscript;

variables;
short ranpc,chief,readbook,enterroom,fate,restsleep,dialog;

body;

beginstate 0;

set_crime_tolerance(1);

if(get_flag(2,1) >= 52){
	erase_char(8);
}
if(get_flag(2,1) >= 2){
	erase_char(7);
}

if(get_flag(2,1) >= 50){
	move_item_on_spot(17,7,-1,-1);
}

if(get_flag(2,1) == 75){
	force_instant_terrain_redraw();
	message_dialog("As you return victorious into town, one of the Speres at the guardpost calls out to you.  _You!  Have you returned with the gem?_","You wave it proudly, and they begin clapping their hands and cheering.");
	if(party_size() > 1){
		message_dialog("One of them leaps down and pats you on the shoulder.  _The Chief and Wiseman Barbarus are waiting for you by the Holy Gate._","_Brave Speres, the tribe is proud of all of you.  Now go, and fulfill your duty as guards of the holiest artifact._");
	}
	else{
		message_dialog("One of them leaps down and pats you on the shoulder.  _The Chief and Wiseman Barbarus are waiting for you by the Holy Gate._","_Brave Spere, the tribe is proud of you.  Now go, and fulfil your duty as guards of the holiest artifact._");
	}
	set_flag(2,1,76);
	activate_hidden_group(5);
	erase_char(6);
}

set_name(12,"Smid");
set_name(15,"Hapud");
set_name(27,"Magos");
set_name(28,"Geoguth");

break;

beginstate 1;

	if(get_flag(2,1) >= 80){
		if(get_current_tick() < 29500){
			while(get_current_tick() < 29500){
				set_ticks_forward(50);
			}
			force_instant_terrain_redraw();
		}
	}

break;

beginstate START_STATE;

	if(get_flag(21,1) >= 1 && get_flag(2,1) < 100){
		inc_flag(21,1,1);
		if(get_flag(21,1) == 6){
			message_dialog("You are making plenty of noise fighting Chief Licgan.","You can hear guards outside beginning to huddle around the Chief's house.  If they bust in, they will immediately believe Licgan, and you will be slain.");
		}
		if(get_flag(21,1) == 15){
			message_dialog("The guards are in the foyer of Licgan's house, and are closing in on his room!","Kill the chief quickly, or else the fact that his word is law will have you doomed!");
		}
		if(get_flag(21,1) == 19){
			message_dialog("You're almost entirely out of time, since the guards are almost in sight.","Finish off Chief Licgan NOW!");
		}
		if(get_flag(21,1) >= 20){
			activate_hidden_group(14);
			set_total_visibility(1);
			force_view_center(52,25);
			force_instant_terrain_redraw();
			pause(10);
			reset_dialog();
			add_dialog_str(0,"Too late!  The Speres, led by an infuriated and distraught Barbarus, enter the room.  Licgan immediately jumps back and points his claymore at you.",0);
			add_dialog_str(1,"_Thank the spirits!  These brigands were attacking me, mumbling nonsense about my being a murderer!  They're insane!  Kill them now!",0);
			add_dialog_str(2,"Barbarus raises his hand in confusion, but is quickly pushed aside by a stream of raging Speres who push you against the wall.",0);
			add_dialog_str(3,"At least your death is a quick one.",0);
			add_dialog_choice(0,"Drat.");
			dialog = run_dialog(1);
			kill_char(1000,1,0);
			end_scenario(0);
		}
	}

	if(char_has_item(0,445) == 1 || char_has_item(1,445) == 1 || char_has_item(2,445) == 1 || char_has_item(3,445) == 1){
		set_flag(15,1,1);
	}

break;

beginstate 10;

if(get_flag(2,1) == 0){
	message_dialog("Wihcaser isn't with you today.  This is strange, considering that he usually is a late riser.","He has likely climbed to the Holy Gate already.  You should check there for him.");
	set_flag(2,1,1);
}

break;

beginstate 11;

if(get_flag(2,1) < 50){
	message_dialog("That is the wrong way.  The Holy Gate is at the top of the hill, not the bottom!","You have no business here yet.");
	block_entry(1);
}

break;

beginstate 12;

if(get_flag(2,1) == 2){
	message_dialog("You finally pass beyond the threshold of Holy Gate.  The inside is damp and cool, almost dramatically so.","Wihcaser, who seemed proud and uppity by suggesting the idea, now seems nervous to an extreme.");
	set_flag(2,1,3);
}

break;

beginstate 13;

if(get_flag(2,1) < 50){
	message_dialog("That is the wrong way.  The Holy Gate is at the top of the hill, not the bottom!","You have no business here yet.");
	block_entry(1);
}
if(get_flag(2,1) == 50){
	message_dialog("That is the wrong way.  The guardpost is to the south at the bottom of the hill, not to the east!","You have no business here yet.");
	block_entry(1);
}
if(get_flag(2,1) == 51){
	message_dialog("That is the wrong way.  The chief is in the center of town, at the meeting hall.  He is not in this direction.","You have no business here yet.");
	block_entry(1);
}

break;

beginstate 14;

if(get_flag(2,1) == 3){
	message_dialog("Wihcaser's fists are clenched, and despite the cool temperature of the cave, he is sweating profusely.  You ask him if something is bothering him.","_No...  Nothing.  I'm fine, let's keep going._  Is your brother genuinely well?");
	set_flag(2,1,4);
}

break;

beginstate 15;

if(get_flag(2,1) == 4){
	message_dialog("You stop and suggest that you not go further.  Wihcaser shakes his head.  _We can come back soon, but I wish to see what we guard._","_Let us go only a bit further.  I promise you, a glance is all I need._  Wihcaser is an honest person.  He has entertained you many times, entertaining his curiosity once cannot hurt.");
	set_flag(2,1,5);
}

break;

beginstate 16;

if(get_flag(2,1) < 50){
	set_flag(2,1,50);
	force_view_center(14,7);
	if(remove_char_from_party(101) == 1){
		print_str("Wihcaser has left the party.");
	}
	activate_hidden_group(1);
	if(party_size() == 3){
		relocate_character(29,10,6);
	}
	if(party_size() == 2){
		relocate_character(29,11,6);
	}
	if(party_size() == 1){
		relocate_character(29,12,6);
	}
	relocate_character(0,13,6);
	relocate_character(1,12,6);
	relocate_character(2,11,6);
	relocate_character(3,10,6);
	force_instant_terrain_redraw();
	pause(10);

	text_bubble_on_char(29,"There it is...");
	force_instant_terrain_redraw();
	pause(12);

	text_bubble_on_char(29,"");
	text_bubble_on_char(29,"The Aquos Gem.");
	force_instant_terrain_redraw();
	pause(12);

	text_bubble_on_char(29,"");
	text_bubble_on_char(29,"I wish to see it.");
	force_instant_terrain_redraw();
	pause(12);

	text_bubble_on_char(29,"");
	if(party_size() >= 4){
		relocate_character(29,10,7);
		force_instant_terrain_redraw();
		pause(5);
	}
	if(party_size() >= 3){
		relocate_character(29,11,7);
		force_instant_terrain_redraw();
		pause(5);
	}
	if(party_size() >= 2){
		relocate_character(29,12,7);
		force_instant_terrain_redraw();
		pause(5);
	}
	if(party_size() >= 1){
		relocate_character(29,13,7);
		force_instant_terrain_redraw();
		pause(5);
	}

	relocate_character(29,14,7);
	force_instant_terrain_redraw();
	pause(5);

	relocate_character(29,15,7);
	force_instant_terrain_redraw();
	pause(5);

	relocate_character(29,16,7);
	force_instant_terrain_redraw();
	pause(5);

	ranpc = random_party_member();
	text_bubble_on_char(ranpc,"It truly is beautiful...");
	force_instant_terrain_redraw();
	pause(12);

	text_bubble_on_char(ranpc,"");
	text_bubble_on_char(29,"Indeed.  It is.");
	force_instant_terrain_redraw();
	pause(12);

	text_bubble_on_char(29,"");
	text_bubble_on_char(29,"Enjoy it while it lasts.");
	force_instant_terrain_redraw();
	pause(12);

	ranpc = random_party_member();
	text_bubble_on_char(29,"");
	text_bubble_on_char(ranpc,"What do you mean...?");
	force_instant_terrain_redraw();
	pause(12);

	text_bubble_on_char(ranpc,"");
	move_item_on_spot(17,7,-1,-1);
	force_instant_terrain_redraw();
	pause(5);

	set_character_facing(29,2);
	force_instant_terrain_redraw();
	pause(12);

	text_bubble_on_char(29,"It's mine now.");
	force_instant_terrain_redraw();
	pause(12);

	ranpc = random_party_member();
	text_bubble_on_char(29,"");
	text_bubble_on_char(ranpc,"Wihcaser...!");
	force_instant_terrain_redraw();
	pause(12);

	text_bubble_on_char(ranpc,"");
	text_bubble_on_char(ranpc,"What are you thinking?");
	force_instant_terrain_redraw();
	pause(12);

	text_bubble_on_char(ranpc,"");
	ranpc = random_party_member();
	text_bubble_on_char(ranpc,"This is just a joke, right?");
	force_instant_terrain_redraw();
	pause(15);

	text_bubble_on_char(ranpc,"");
	if(party_size() >= 2){
		text_bubble_on_char(29,"Farewell, brothers.");
	}
	else{
		text_bubble_on_char(29,"Farewell, brother.");
	}
	force_instant_terrain_redraw();
	pause(12);

	text_bubble_on_char(29,"");
	text_bubble_on_char(29,"Don't hate me when I'm gone.");
	force_instant_terrain_redraw();
	pause(15);

	text_bubble_on_char(29,"");
	set_character_pose(29,2);
	force_instant_terrain_redraw();
	play_sound(18);
	pause(5);

	relocate_character(29,15,7);
	force_instant_terrain_redraw();
	pause(2);

	relocate_character(29,14,7);
	force_instant_terrain_redraw();
	pause(2);

	relocate_character(29,13,7);
	force_instant_terrain_redraw();
	pause(2);

	relocate_character(29,12,7);
	force_instant_terrain_redraw();
	pause(2);

	relocate_character(29,11,7);
	force_instant_terrain_redraw();
	pause(2);

	relocate_character(29,10,8);
	force_instant_terrain_redraw();
	pause(2);

	relocate_character(29,9,8);
	force_instant_terrain_redraw();
	pause(2);

	relocate_character(29,8,9);
	set_character_facing(29,4);
	force_instant_terrain_redraw();
	pause(2);

	relocate_character(29,8,10);
	force_instant_terrain_redraw();
	pause(2);

	relocate_character(29,9,11);
	force_instant_terrain_redraw();
	pause(2);

	erase_char(29);

	message_dialog("Wihcaser!  What just happened?  Unless you're hallucinating, your brother in arms just stole the holiest artifact of the Emerald Tribe.","Wihcaser is a swift runner.  He has likely already left the city.");
	message_dialog("Perhaps the Speres at the guardpost saw which direction he ran off in.  You had best check with them first.","");
	block_entry(1);
}

break;

beginstate 17;

if(get_flag(2,1) < 51){
	message_dialog("That is the wrong way.  The guardpost is to the south at the bottom of the hill, not to the east!","You have no business here yet.");
	block_entry(1);
}

break;

beginstate 18;

if(get_flag(2,1) == 51){
	message_dialog("That is the wrong way.  The chief is in the center of town, at the meeting hall.  He is not in this direction.","You have no business here yet.");
	block_entry(1);
}

break;

beginstate 19;

	if(get_flag(2,1) < 80){
		message_dialog("This is the Chief's quarters.  You are explicitly not allowed inside.","");
		block_entry(1);
	}
	if(get_flag(2,1) == 80){
		reset_dialog();
		add_dialog_str(0,"This is the Chief's quarters.  You are explicitly not allowed inside.",0);
		add_dialog_str(1,"Still, there is no guard standing at the entrance.  If you chose, you could sneak inside.",0);
		add_dialog_str(2,"It could be dangerous and you stand to get in deep trouble, however...",0);
		add_dialog_choice(0,"Don't enter.");
		add_dialog_choice(1,"Enter.");
		chief = run_dialog(0);
		if(chief == 1){
			block_entry(1);
			end();
		}
		else{
			set_flag(2,1,81);
		}
	}

break;

beginstate 20;

	if(get_flag(2,1) == 50){
		message_dialog("You must consult the Speres at the guardpost first before leaving.","");
		block_entry(1);
	}
	if(get_flag(2,1) == 51){
		message_dialog("You must consult Chief Licgan at the Meeting Hall first before leaving.","");
		block_entry(1);
	}
	if(get_flag(2,1) == 52){
		message_dialog("You must consult Wiseman Barbarus first before leaving.","");
		block_entry(1);
	}
	if(get_flag(2,1) > 75){
		message_dialog("You have no reason to leave the village with your holy quest completed.","");
		block_entry(1);
	}

break;

beginstate 21;

	if(get_flag(2,1) == 76){
		message_dialog("Chief Licgan and Wiseman Barbarus are already standing around the platform where the Aquos Gem should go.  Chief Licgan nods at you.","_Come.  It is time to do what must be done._");

		relocate_character(0,15,7);
		relocate_character(1,15,6);
		relocate_character(2,15,8);
		relocate_character(3,14,7);
		set_character_facing(1000,6);
		force_instant_terrain_redraw();
		pause(10);

		relocate_character(33,17,8);
		force_instant_terrain_redraw();
		pause(5);

		relocate_character(33,16,7);
		set_character_facing(33,2);
		force_instant_terrain_redraw();
		pause(7);

		text_bubble_on_char(33,"Give me the Aquos Gem,");
		force_instant_terrain_redraw();
		pause(12);

		text_bubble_on_char(33,"");
		if(party_size() > 1){
			text_bubble_on_char(33,"Brave Speres.");
		}
		else{
			text_bubble_on_char(33,"Brave Spere.");
		}
		force_instant_terrain_redraw();
		pause(10);

		ranpc = random_party_member();
		text_bubble_on_char(33,"");
		text_bubble_on_char(ranpc,"Yes sir.");
		change_spec_item(10,-1);
		force_instant_terrain_redraw();
		pause(7);

		text_bubble_on_char(ranpc,"");
		set_character_facing(33,6);
		force_instant_terrain_redraw();
		pause(5);

		put_item_on_spot(17,7,445);
		force_instant_terrain_redraw();
		pause(5);

		set_character_pose(33,1);
		text_bubble_on_char(33,"*chanting*");
		force_instant_terrain_redraw();
		play_sound(24);
		pause(5);

		set_character_pose(33,0);
		text_bubble_on_char(33,"");
		force_instant_terrain_redraw();
		pause(5);

		set_character_pose(33,1);
		text_bubble_on_char(33,"*chanting*");
		force_instant_terrain_redraw();
		play_sound(24);
		pause(5);

		set_character_pose(33,0);
		text_bubble_on_char(33,"");
		force_instant_terrain_redraw();
		pause(5);

		set_character_pose(33,1);
		text_bubble_on_char(33,"*chanting*");
		force_instant_terrain_redraw();
		play_sound(24);
		pause(5);

		set_character_pose(33,0);
		text_bubble_on_char(33,"");
		force_instant_terrain_redraw();
		pause(5);

		text_bubble_on_char(33,"The spirits will now");
		force_instant_terrain_redraw();
		pause(10);

		text_bubble_on_char(33,"");
		text_bubble_on_char(33,"bless us once more.");
		force_instant_terrain_redraw();
		pause(10);

		text_bubble_on_char(33,"");
		text_bubble_on_char(33,"My work here");
		force_instant_terrain_redraw();
		pause(10);

		text_bubble_on_char(33,"");
		text_bubble_on_char(33,"is finished.");
		force_instant_terrain_redraw();
		pause(8);

		message_dialog("Wiseman Barbarus and Chief Licgan both leave the cave, and so do you shortly thereafter.","You return to your house and fall asleep.  It has been a long day.");

		while(get_current_tick() < 29500){
			set_ticks_forward(50);
		}
		force_instant_terrain_redraw();
		relocate_character(0,12,32);
		relocate_character(1,12,31);
		relocate_character(2,12,30);
		relocate_character(3,12,29);
		force_view_center(12,32);
		set_terrain(20,22,28);
		force_instant_terrain_redraw();
		pause(5);

		message_dialog("It's the middle of the night, and you shouldn't be awake.  But something is bothering you.","It's probably nothing, but just a hunch...");

		march_party(13,32);
		force_view_center(13,32);
		force_instant_terrain_redraw();
		pause(5);

		march_party(14,33);
		force_view_center(14,33);
		force_instant_terrain_redraw();
		pause(5);

		march_party(15,33);
		force_view_center(15,33);
		force_instant_terrain_redraw();
		pause(5);

		march_party(16,33);
		force_view_center(16,33);
		force_instant_terrain_redraw();
		pause(5);

		march_party(17,32);
		force_view_center(17,32);
		force_instant_terrain_redraw();
		pause(5);

		march_party(18,31);
		force_view_center(18,31);
		force_instant_terrain_redraw();
		pause(5);

		march_party(19,31);
		force_view_center(19,31);
		force_instant_terrain_redraw();
		pause(5);

		message_dialog("It's late in the evening.  If you want to fall asleep, you should probably get back inside.  Still, there is a lingering suspicion that you have...","Something about the goblins, especially their chief, did not sit well with you.");
		message_dialog("Taking a stroll might not be a bad idea, but you do need your sleep.  To go back to bed and put your worries to rest, re-enter your house.","");
		block_entry(1);
		set_flag(2,1,80);
		erase_char(13);
		erase_char(23);
		erase_char(24);
		erase_char(25);
		erase_char(26);

	}
break;

beginstate 22;

	if(get_flag(2,1) >= 80 && get_flag(20,1) < 2){
		message_dialog("It is the evening, and Wiseman Barbarus is asleep, not to be disturbed.","You see no need to consult him, so you leave him alone.");
		block_entry(1);
	}
	if(get_flag(2,1) >= 80 && get_flag(20,1) == 2 && get_flag(13,1) == 0){
		message_dialog("It is the evening, and Wiseman Barbarus is not to be disturbed.","Still, you feel that you should consult him about what to do.  You ask the guard if you can see him.");
		message_dialog("The guard goes inside for a few seconds, and emerges.","_You may see Wiseman Barbarus if you please.  He has granted you permission._");
		set_flag(13,1,1);
		activate_hidden_group(13);
	}

break;

beginstate 23;

	if(get_flag(2,1) < 82){
		message_dialog("You enter the chief's home for the first time.  It seems as if he has an entrance hall, rather than just a bedroom.","This is not entirely unexpected, considering how powerful and honorable he is.  You can hear the chief snoring.  He must be asleep, so you must be quiet while roaming about his house.");
		set_flag(2,1,82);
	}

break;

beginstate 24;

	if(get_flag(2,1) < 83){
		message_dialog("There is a solemn altar here on a raised platform.  This must be where the chief prays to the spirits.","");
		set_flag(2,1,83);
	}

break;

beginstate 25;

	if(get_flag(2,1) < 84){
		message_dialog("This is the chief's library.  There are wooden scroll shelves along the wall holding scrolls.","");
		set_flag(2,1,84);
	}

break;

beginstate 26;

	if(get_flag(20,1) < 2){
		message_dialog("This is the bedchamber of Chief Licgan.  You can tell, since the snoring is so loud.","If you were to get any closer, the chief might wake up, getting you in serious trouble.");
		block_entry(1);
		end();
	}
	if(get_flag(20,1) >= 2){
		reset_dialog();
		add_dialog_str(0,"This is the bedchamber of Chief Licgan.  You can tell, since the snoring is so loud.",0);
		add_dialog_str(1,"If you wanted to, you could confront him about the evidence you have, and maybe you might get some answers.",0);
		add_dialog_choice(0,"Leave him alone.");
		add_dialog_choice(1,"Enter his room.");
		enterroom = run_dialog(0);
		if(enterroom == 1){
			block_entry(1);
			end();
		}
		else{

			message_dialog("You knock on the Chief's wall.  You hear him get out of bed.  _What is it?  If you woke me up, at least come in!  And make it quick, please._","");

			activate_hidden_group(12);
			march_party(50,25);
			force_view_center(50,25);
			force_instant_terrain_redraw();
			pause(5);

			march_party(51,25);
			force_view_center(50,25);
			force_instant_terrain_redraw();
			pause(5);

			march_party(52,25);
			force_view_center(50,25);
			force_instant_terrain_redraw();
			pause(5);

			march_party(53,25);
			force_view_center(50,25);
			force_instant_terrain_redraw();
			pause(5);

			set_character_facing(1000,4);
			text_bubble_on_char(0,"Chief Licgan,");
			force_instant_terrain_redraw();
			pause(10);

			text_bubble_on_char(0,"");
			text_bubble_on_char(0,"We have questions for you.");
			force_instant_terrain_redraw();
			pause(10);

			text_bubble_on_char(0,"");
			text_bubble_on_char(34,"Come in, then!");
			force_instant_terrain_redraw();
			pause(10);

			march_party(54,25);
			force_view_center(50,25);
			force_instant_terrain_redraw();
			pause(5);

			march_party(55,25);
			force_view_center(50,25);
			force_instant_terrain_redraw();
			pause(5);

			march_party(56,25);
			force_view_center(50,25);
			force_instant_terrain_redraw();
			pause(5);

			set_character_facing(1000,4);
			ranpc = random_party_member();
			text_bubble_on_char(34,"");
			text_bubble_on_char(ranpc,"We found your axe");
			force_instant_terrain_redraw();
			pause(10);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"on the body of");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"the Goblin Chief.");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(34,"How do you know");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(34,"");
			text_bubble_on_char(34,"that it's my axe?");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(34,"");
			ranpc = random_party_member();
			text_bubble_on_char(ranpc,"We spoke with Smid.");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"He assured us that");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"he gave his finest axe");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"to you.");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			ranpc = random_party_member();
			text_bubble_on_char(ranpc,"If the axe we found");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"wasn't yours,");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"then show it to us.");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(34,"...");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(34,"");
			text_bubble_on_char(34,"I...");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(34,"");
			text_bubble_on_char(34,"I don't have it!");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(34,"");
			text_bubble_on_char(34,"That still doesn't prove");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(34,"");
			text_bubble_on_char(34,"that I gave it");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(34,"");
			text_bubble_on_char(34,"to the goblins.");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(34,"");
			ranpc = random_party_member();
			text_bubble_on_char(ranpc,"But you still had it");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"when you left.");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"You were carrying it!");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			ranpc = random_party_member();
			text_bubble_on_char(ranpc,"So you gave the axe");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"to the goblin chief");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"after they took the gem?");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(34,"...");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(34,"");
			ranpc = random_party_member();
			text_bubble_on_char(ranpc,"Are you saying");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"that you support their");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"keeping the gem?");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(34,"Enough!");
			force_instant_terrain_redraw();
			pause(12);

			text_bubble_on_char(34,"");
			text_bubble_on_char(34,"I will tell you everything.");
			force_instant_terrain_redraw();
			pause(12);


			text_bubble_on_char(34,"");
			force_instant_terrain_redraw();
	reset_dialog();
	add_dialog_str(0,"_Two years ago was the day that I was appointed to become chief of Emerald Valley and our tribe.  It was a stormy day, complete with rain and everything._",0);
	add_dialog_str(1,"_Barbarus was presiding over the ceremony.  Wihcaser was our village's most promising warrior, but he was absent, and nobody knew why.  It was assumed that he didn't want the position._",0);
	if(party_size() > 1){
		add_dialog_str(2,"_But I know, and so did Wihcaser.  I told him that his brothers-in-arms were praying at the Holy Mound, and that he should gather them for the ceremony.  You were just oversleeping, but he never checked._",0);
		add_dialog_str(3,"_Two hours later, during the celebration of my ascension, Wihcaser returned to find all of you carousing merrily.  It was done, and I became chief of the village._",0);
	}
	else{
		add_dialog_str(2,"_But I know, and so did Wihcaser.  I told him that his brother-in-arms was praying at the Holy Mound, and that he should gather him for the ceremony.  You were just oversleeping, but he never checked._",0);
		add_dialog_str(3,"_Two hours later, during the celebration of my ascension, Wihcaser returned to find you carousing merrily.  It was done, and I became chief of the village._",0);
	}
	add_dialog_str(4,"_But as of late, I feared that Wihcaser has been becoming cagey.  I couldn't let the only other person who knows my secret live._",0);
	add_dialog_str(5,"_I calculated a plan that would definitely work._",0);
	add_dialog_choice(0,"A plan...?");
	readbook = run_dialog(1);

	reset_dialog();
	if(party_size() > 1){
		add_dialog_str(0,"_I had ordered Wihcaser to steal the Aquos Gem and tell nobody about it, not even Barbarus or his most beloved brothers-in-arms._",0);
	}
	else{
		add_dialog_str(0,"_I had ordered Wihcaser to steal the Aquos Gem and tell nobody about it, not even Barbarus or his most beloved brother-in-arms._",0);
	}
	add_dialog_str(1,"_I told him then to flee the village and stand in the opening to the valley of the goblin village and wait there for a few days.  He was to do so until tomorrow._",0);
	add_dialog_str(2,"_What he didn't know is that I too left the village shortly after it was reported that he has robbed the Aquos Gem.  I snuck up behind him and slew him.  Yes, I slew your precious Wihcaser!_",0);
	add_dialog_str(3,"_I took my axe to the goblin chief, gave him the Aquos Gem, and told him to hide the gem for a few days, and that I would pick it up soon.  The axe was payment, you see._",0);
	add_dialog_str(4,"_I was hoping that you would die from the goblins, so I could recover the gem and get glory.  But now, my plans are shattered.  Or at least, they almost are._",0);
	add_dialog_str(5,"_Now, I can kill you, and silence everything!  Wihcaser, you and the goblins all dead:  Nobody will know my secret!_",0);
	add_dialog_choice(0,"Why did you do it?");
	dialog = run_dialog(1);

	reset_dialog();
	add_dialog_str(0,"_Why did I do it, you ask?  Power.  Power controls all.  Beliefs are hollow, and can be manipulated.  But power in your hands is the only absolute!_",0);
	add_dialog_str(1,"_I am the word.  I am the law.  I have the power, and the more I get, the more whatever I want becomes reality!  I can shape truth and morality with these two hands._",0);
	add_dialog_str(2,"_And even though you may know what I did, I can silence you and make my own world!  Truth is defined by the winners, and I will not lose!_",0);
	add_dialog_choice(0,"You bastard...!");
	dialog = run_dialog(1);

			ranpc = random_party_member();
			text_bubble_on_char(ranpc,"Honor,");
			force_instant_terrain_redraw();
			pause(10);

			text_bubble_on_char(ranpc,"");
			ranpc = random_party_member();
			text_bubble_on_char(ranpc,"Tradition,");
			force_instant_terrain_redraw();
			pause(10);

			text_bubble_on_char(ranpc,"");
			ranpc = random_party_member();
			text_bubble_on_char(ranpc,"and Conviction.");
			force_instant_terrain_redraw();
			pause(10);

			text_bubble_on_char(ranpc,"");
			ranpc = random_party_member();
			text_bubble_on_char(ranpc,"You die now,");
			force_instant_terrain_redraw();
			pause(10);

			text_bubble_on_char(ranpc,"");
			text_bubble_on_char(ranpc,"false chief!");
			force_instant_terrain_redraw();
			pause(10);

			text_bubble_on_char(ranpc,"");
			force_instant_terrain_redraw();
			set_flag(2,1,95);
			set_attitude(34,10);
			block_entry(1);

set_flag(21,1,1);
print_str_color("WARNING:",1);
print_str_color("You have LIMITED TIME to win this fight.",1);
		}
	}

break;

beginstate 27;

	if(get_flag(2,1) < 100){
		message_dialog("You can't leave yet!  You still have to slay Chief Licgan and extract your vengeance.","");
		block_entry(1);
	}
	else{
		reset_dialog();
		add_dialog_str(0,"Chief Licgan is dead.  Despite no guards being in the area, plenty heard the fight, and are waiting outside of the chief's house as you emerge.  They see blood on you and assume the worst.",0);
		add_dialog_str(1,"Fortunately for you, Wiseman Barbarus is among them, and tells the crowd to wait for you to explain.  You tell them about Licgan's treachery and murder, that he is responsible for the robbery.",0);
		add_dialog_str(2,"Wiseman Barbarus and you re-enter Licgan's home, and you explain the situation to him.  He is shocked and furious.   He shakes his head, scowls, and turns to you.",0);
		add_dialog_str(3,"_You serve our tribe with your honor once more.  I cannot tell you how shocked I am to know that I trusted that fiend.  I assure you, these travesties will never happen again._",0);
		add_dialog_str(4,"Barbarus explains to the crowd that Licgan was never their chief, and had the rightful heir to their tribe murdered.  The entire crowd goes silent with shame.",0);
		add_dialog_str(5,"Everyone shuffles back to their homes and guardposts until the next morning.",0);
		fate = run_dialog(1);

		erase_char(22);
		erase_char(21);
		relocate_character(0,32,39);
		relocate_character(1,31,39);
		relocate_character(2,33,39);
		relocate_character(3,32,40);
		set_character_facing(1000,0);
		activate_hidden_group(10);
		erase_char(35);
		force_view_center(32,39);
		force_instant_terrain_redraw();
		pause(10);


		reset_dialog();
		if(party_size() > 1){
			add_dialog_str(0,"The next day, Barbarus holds a ceremony appointing all of you as joint chiefs of the tribe.  It is unusual, but few people argue against it.",0);
		}
		else{
			add_dialog_str(0,"The next day, Barbarus holds a ceremony appointing you as chief of the tribe.  Few people argue against it.",0);
		}
		add_dialog_str(1,"Your first action is to collect Wihcaser's body and have it buried in the Holy Mound.  Nobody will be able to bring your beloved brother back, but he stood for everything your tribe holds dear.",0);
		add_dialog_str(2,"Honor, Tradition and Conviction.",0);
		add_dialog_str(3,"You lead the tribe as best you can, but it's difficult knowing that you had to serve under a lie, and that your brother-in-arms who should rightfully rule never will.",0);
		add_dialog_str(4,"You have come to know everything about your tribe and the mystery surrounding your ascension.  Still, one lingering thought remains.  Licgan died saying that you and he were the same.  All you can do is devote your lives to being different.",0);
		add_dialog_str(5," - THE END - ",20);
		fate = run_dialog(1);
		if(get_flag(20,1) >= 3){
			if(reward_give(458) == 1){
				message_dialog("Barbarus gives you a glistening pair of gloves.  _These are a reward for your incredible service to the tribe._","_It is my offer of generosity for defending our honor.  Wear them proudly._");
			}
		}

		award_party_xp(1000,100);
		block_entry(1);
		end_scenario(1);
	}

break;

beginstate 28;

		if(get_flag(2,1) >= 80){
	reset_dialog();
	add_dialog_str(0,"You could, if you wanted to, fall back asleep.",0);
	if(get_flag(2,1) >= 90){
		add_dialog_str(1,"You could confront Licgan, but perhaps it's just best to trust in the power of authority.",0);
	}
	add_dialog_choice(0,"Go to bed.");
	add_dialog_choice(1,"Stay awake.");
	restsleep = run_dialog(0);
	if(restsleep == 2){
		block_entry(1);
		end();
	}
	else{
		while(get_current_tick() < 1000 || get_current_tick() > 4000){
			set_ticks_forward(50);
		}

		erase_char(22);
		erase_char(21);
		relocate_character(0,32,39);
		relocate_character(1,31,39);
		relocate_character(2,33,39);
		relocate_character(3,32,40);
		set_character_facing(1000,0);
		activate_hidden_group(10);
		force_view_center(32,39);
		force_instant_terrain_redraw();
		pause(10);

		reset_dialog();
		add_dialog_str(0,"You are summoned next morning by Wiseman Barbarus.  You are taken to the center of the village, where the tribe's Speres are there to congratulate you.",0);
		if(get_flag(2,1) >= 90){
			add_dialog_str(1,"Chief Licgan is also here.  His arms are folded, and he is smiling widely.  You could have confronted him last night, but now...",0);
		}
		else{
			add_dialog_str(1,"Chief Licgan is also here.  His arms are folded, and he is smiling widely.  He seems quite proud of your actions.",0);
		}
		if(party_size() > 1){
			add_dialog_str(2,"Wiseman Barbarus smiles and points his staff at you.  _These are the Speres who saved our village!  Great honor is with them._",0);
		}
		else{
			add_dialog_str(2,"Wiseman Barbarus smiles and points his staff at you.  _This is the Spere who saved our village!  Great honor is with him._",0);
		}
		if(reward_give(458) == 1){
			add_dialog_str(3,"Barbarus produces a pair of glistening gloves from his robes.  _These are your reward for recovering the Aquos Gem._",0);
		}
		else{
			add_dialog_str(3,"Barbarus raises his staff.  _We have no reward for these warriors, but let us always remember their deeds._",0);
		}
		add_dialog_str(4,"The Speres of the village all raise their weapons and cheer for you.  It's somewhat overwhelming.",0);
		restsleep = run_dialog(1);

		reset_dialog();
		add_dialog_str(0,"Life after that day went on as usual.  Nothing went wrong at the Holy Gate.",0);
		if(get_flag(2,1) >= 90){
			add_dialog_str(1,"You have always suspected Licgan of what he did, but have never found the courage to confront him about it.  Perhaps some things are best left unanswered.",0);
		}
		else{
			add_dialog_str(1,"There has always been something of a suspicion regarding Wihcaser's death, but since then you have learned to put it behind you as best as you can.",0);
		}
		add_dialog_str(2,"Life in your tribe goes on as usual.",0);
		add_dialog_str(3,"Honor, Tradition and Conviction.",0);
		add_dialog_str(4," --- ",0);
		add_dialog_str(5," - THE END - ",20);
		restsleep = run_dialog(1);
		block_entry(1);

		end_scenario(1);
	}
		}

break;
